Zero-shot Prompting

Learn about the zero-shot prompting technique and its limitations.

Overview#

Zero-shot prompting is a prompting technique that involves generating text without any training on the specific task at hand. Instead, the generative AI system uses a pre-existing language model trained on diverse tasks to generate text for a new task without additional training or fine-tuning. Zero-shot prompting allows for quick and easy adaptation to new tasks without requiring large amounts of task-specific training data.

Most LLMs like GPT-3 are aligned to follow instructions by applying reinforcement learning with human feedback in the loop (RLHF), so zero-shot prompts with relevant context tend to perform incredibly well with these models.

The zero-shot prompting technique
The zero-shot prompting technique

A good strategy for prompt engineering is to start with zero-shot prompts and use more advanced techniques only if it does not produce the desired output.

Examples#

Let's look at some examples of zero-shot prompting in the context of different prompt types.

Classification#

To use zero-shot prompting with classification, we can provide the model with a prompt that includes a description of the category we want to classify the text into. For example, we could provide the following prompt:

Prompt

Classify the following text as either a review of a Chinese restaurant or a review of an Italian restaurant.

"I had the most amazing pasta at this restaurant. The sauce was perfectly seasoned and the noodles were cooked to perfection."

Output

The following text is a review of an Italian restaurant.

The model uses its understanding of language and context to classify the text as a review of an Italian restaurant, even though it has not been specifically trained on that category. This is because the model can infer the characteristics of Italian cuisine based on its training on other related categories.

Information extraction#

We can use zero-shot prompting to extract information like keywords from some text. For example, we can use the following prompt to extract keywords from an email:

Prompt

Extract the keywords/key phrases from the following email:


Dear John,

Please note that the marketing team will be meeting tomorrow at noon to discuss the Q3 plans. We will be creating our to-dos and assigning priorities. You are responsible for taking the meeting notes, so please make sure to attend.

Regards,

Manager Ken

Output

Keywords/key phrases: John, marketing team, meeting, tomorrow, noon, Q3 plans, to-dos, assigning priorities, meeting notes, attend, Manager.

Here, the model extracts the key information in the email based on its existing training. We do not provide any additional information regarding how the model should identify the keywords.

Limitations#

While zero-shot prompting is a powerful technique, it has several limitations that do not make it suitable for many use cases. Here are some reasons why zero-shot prompting can be ineffective:

  • Control: Zero-shot prompting limits the control we have over the output. The model generates a response based on its own understanding of the prompt. Using this technique, we can’t guide the model to respond in a certain way.
svg viewer
  • Complex tasks: Zero-shot prompting may not work well for complex tasks that require multiple steps or a deep understanding of the underlying domain. It may require fine-tuning or additional information about the task to be able to solve it.
svg viewer
  • Specialized domain: Zero-shot prompting may struggle with rare or specialized domains, as the model has not been trained on specific examples of these domains.
svg viewer
  • Long-form text: Zero-shot prompting is often used to generate short-form text, such as headlines or descriptions. It may not work well for longer-form text like articles or reports as they may require multiple inputs and constant guidance to achieve a desired result.
svg viewer

Although zero-shot prompting is a fast and easy-to-use prompting technique, we know that it can fail to respond accurately in certain circumstances. However, there are a few other prompting techniques that can help us overcome these limitations.

Quiz: Introduction to Prompt Engineering

Few-shot Prompting